// 商家数据
const businessData = {
    1: {
        name: "万家饺子（软件园E18店）",
        image: "img/sj01.png",
        description: "各种饺子炒菜",
        delivery: "￥15起送 ￥3配送",
        foods: [
            { image: "img/sp01.png", name: "纯肉鲜肉（水饺）", desc: "新鲜猪肉", price: "￥15", quantity: 3 },
            { image: "img/sp02.png", name: "玉米鲜肉（水饺）", desc: "玉米鲜肉", price: "￥16", quantity: 2 },
            { image: "img/sp03.png", name: "虾仁三鲜（蒸饺）", desc: "虾仁三鲜", price: "￥22", quantity: 0 },
            { image: "img/sp04.png", name: "素三鲜（蒸饺）", desc: "素三鲜", price: "￥15", quantity: 0 },
            { image: "img/sp05.png", name: "角瓜鸡蛋（蒸饺）", desc: "角瓜鸡蛋", price: "￥16", quantity: 0 },
            { image: "img/sp06.png", name: "小白菜肉（水饺）", desc: "小白菜肉", price: "￥18", quantity: 0 },
            { image: "img/sp07.png", name: "芹菜牛肉（水饺）", desc: "芹菜牛肉", price: "￥18", quantity: 0 },
            { image: "img/sp08.png", name: "虾滑鲜肉（水饺）", desc: "鲜美虾滑", price: "￥20", quantity: 0 },
            { image: "img/sp09.png", name: "青椒鲜肉（蒸饺）", desc: "青椒鲜肉", price: "￥17", quantity: 0 }
        ]
    },
    2: {
        name: "小锅饭豆腐馆（全运店）",
        image: "img/sj02.png",
        description: "特色美食",
        delivery: "￥15起送 ￥3配送",
        foods: [
            { image: "img/sp10.png", name: "麻婆豆腐", desc: "经典川菜", price: "￥18", quantity: 0 },
            { image: "img/sp11.png", name: "家常豆腐", desc: "家常口味", price: "￥16", quantity: 0 },
            { image: "img/sp12.png", name: "红烧豆腐", desc: "红烧口味", price: "￥17", quantity: 0 },
            { image: "img/sp01.png", name: "白米饭", desc: "优质大米", price: "￥3", quantity: 0 },
            { image: "img/sp02.png", name: "紫菜蛋花汤", desc: "清淡汤品", price: "￥8", quantity: 0 }
        ]
    },
    3: {
        name: "麦当劳（天津大学北洋园店）",
        image: "img/sj03.png",
        description: "汉堡薯条",
        delivery: "￥15起送 ￥3配送",
        foods: [
            { image: "img/sp03.png", name: "巨无霸", desc: "经典汉堡", price: "￥22", quantity: 0 },
            { image: "img/sp04.png", name: "薯条（大）", desc: "金黄薯条", price: "￥12", quantity: 0 },
            { image: "img/sp05.png", name: "麦香鸡", desc: "香嫩鸡肉", price: "￥18", quantity: 0 },
            { image: "img/sp06.png", name: "可乐（中杯）", desc: "冰爽可乐", price: "￥8", quantity: 0 },
            { image: "img/sp07.png", name: "麦乐鸡", desc: "酥脆鸡块", price: "￥15", quantity: 0 }
        ]
    },
    4: {
        name: "米村拌饭（浑南店）",
        image: "img/sj04.png",
        description: "各种炒菜拌饭",
        delivery: "￥15起送 ￥3配送",
        foods: [
            { image: "img/sp08.png", name: "韩式拌饭", desc: "正宗韩味", price: "￥20", quantity: 0 },
            { image: "img/sp09.png", name: "牛肉拌饭", desc: "嫩滑牛肉", price: "￥25", quantity: 0 },
            { image: "img/sp10.png", name: "猪肉拌饭", desc: "香嫩猪肉", price: "￥22", quantity: 0 },
            { image: "img/sp11.png", name: "泡菜汤", desc: "韩式泡菜", price: "￥12", quantity: 0 },
            { image: "img/sp12.png", name: "紫菜汤", desc: "清淡汤品", price: "￥10", quantity: 0 }
        ]
    },
    5: {
        name: "申记串道（中海康城店）",
        image: "img/sj05.png",
        description: "烤串炸串",
        delivery: "￥15起送 ￥3配送",
        foods: [
            { image: "img/sp01.png", name: "羊肉串", desc: "新鲜羊肉", price: "￥5", quantity: 0 },
            { image: "img/sp02.png", name: "牛肉串", desc: "优质牛肉", price: "￥6", quantity: 0 },
            { image: "img/sp03.png", name: "鸡翅", desc: "烤制鸡翅", price: "￥8", quantity: 0 },
            { image: "img/sp04.png", name: "烤肠", desc: "香肠烤制", price: "￥4", quantity: 0 },
            { image: "img/sp05.png", name: "烤玉米", desc: "新鲜玉米", price: "￥6", quantity: 0 }
        ]
    },
    6: {
        name: "半亩良田排骨米饭",
        image: "img/sj06.png",
        description: "排骨米饭套餐",
        delivery: "￥15起送 ￥3配送",
        foods: [
            { image: "img/sp06.png", name: "红烧排骨饭", desc: "经典排骨", price: "￥25", quantity: 0 },
            { image: "img/sp07.png", name: "糖醋排骨饭", desc: "酸甜口味", price: "￥26", quantity: 0 },
            { image: "img/sp08.png", name: "蒜香排骨饭", desc: "蒜香浓郁", price: "￥24", quantity: 0 },
            { image: "img/sp09.png", name: "冬瓜排骨汤", desc: "清淡汤品", price: "￥15", quantity: 0 },
            { image: "img/sp10.png", name: "白米饭", desc: "优质大米", price: "￥3", quantity: 0 }
        ]
    },
    7: {
        name: "茶兮鲜果饮品（国际软件园店）",
        image: "img/sj07.png",
        description: "甜品饮品",
        delivery: "￥15起送 ￥3配送",
        foods: [
            { image: "img/sp11.png", name: "芒果汁", desc: "新鲜芒果", price: "￥18", quantity: 0 },
            { image: "img/sp12.png", name: "草莓奶昔", desc: "浓郁奶香", price: "￥20", quantity: 0 },
            { image: "img/sp01.png", name: "柠檬蜂蜜茶", desc: "清香柠檬", price: "￥16", quantity: 0 },
            { image: "img/sp02.png", name: "珍珠奶茶", desc: "经典奶茶", price: "￥15", quantity: 0 },
            { image: "img/sp03.png", name: "水果拼盘", desc: "时令水果", price: "￥25", quantity: 0 }
        ]
    },
    8: {
        name: "唯一水果捞（软件园E18店）",
        image: "img/sj08.png",
        description: "新鲜水果",
        delivery: "￥15起送 ￥3配送",
        foods: [
            { image: "img/sp04.png", name: "综合水果捞", desc: "多种水果", price: "￥28", quantity: 0 },
            { image: "img/sp05.png", name: "芒果捞", desc: "新鲜芒果", price: "￥22", quantity: 0 },
            { image: "img/sp06.png", name: "草莓捞", desc: "酸甜草莓", price: "￥25", quantity: 0 },
            { image: "img/sp07.png", name: "西瓜汁", desc: "清甜西瓜", price: "￥15", quantity: 0 },
            { image: "img/sp08.png", name: "酸奶水果杯", desc: "酸奶搭配", price: "￥20", quantity: 0 }
        ]
    },
    9: {
        name: "满园春饼（全运路店）",
        image: "img/sj09.png",
        description: "各种春饼",
        delivery: "￥15起送 ￥3配送",
        foods: [
            { image: "img/sp09.png", name: "鸡蛋春饼", desc: "嫩滑鸡蛋", price: "￥12", quantity: 0 },
            { image: "img/sp10.png", name: "土豆丝春饼", desc: "爽脆土豆", price: "￥10", quantity: 0 },
            { image: "img/sp11.png", name: "豆芽春饼", desc: "清脆豆芽", price: "￥8", quantity: 0 },
            { image: "img/sp12.png", name: "韭菜春饼", desc: "香嫩韭菜", price: "￥9", quantity: 0 },
            { image: "img/sp01.png", name: "肉丝春饼", desc: "香嫩肉丝", price: "￥15", quantity: 0 }
        ]
    }
};

// 获取URL参数
function getUrlParameter(name) {
    const urlParams = new URLSearchParams(window.location.search);
    return urlParams.get(name);
}

// 页面加载时初始化
window.onload = function() {
    const businessId = getUrlParameter('id') || '1'; // 默认显示第一个商家
    const business = businessData[businessId];
    
    if (business) {
        // 更新商家logo
        document.querySelector('.business-logo img').src = business.image;
        
        // 更新商家信息
        document.querySelector('.business-info h1').textContent = business.name;
        document.querySelector('.business-info p:first-of-type').innerHTML = business.delivery;
        document.querySelector('.business-info p:last-of-type').textContent = business.description;
        
        // 更新食品列表
        const foodList = document.querySelector('.food');
        foodList.innerHTML = '';
        
        business.foods.forEach(food => {
            const li = document.createElement('li');
            li.innerHTML = `
                <div class="food-left">
                    <img src="${food.image}">
                    <div class="food-left-info">
                        <h3>${food.name}</h3>
                        <p>${food.desc}</p>
                        <p>${food.price}</p>
                    </div>
                </div>
                <div class="food-right">
                    <div>
                        ${food.quantity > 0 ? '<i class="fa fa-minus-circle"></i>' : ''}
                    </div>
                    <p>${food.quantity > 0 ? `<span>${food.quantity}</span>` : ''}</p>
                    <div>
                        <i class="fa fa-plus-circle"></i>
                    </div>
                </div>
            `;
            foodList.appendChild(li);
        });
    }
}; 